#tag Class
Class NSColor
Inherits NSObject
	#tag Method, Flags = &h0
		Function AlphaComponent() As Single
		  
		  #if targetMacOS
		    declare function alphaComponent lib CocoaLib selector "alphaComponent" (id as Ptr) as Single
		    
		    return alphaComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function AlternateSelectedControlColor() As NSColor
		  
		  #if targetMacOS
		    declare function alternateSelectedControlColor lib CocoaLib selector "alternateSelectedControlColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = alternateSelectedControlColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function AlternateSelectedControlTextColor() As NSColor
		  
		  #if targetMacOS
		    declare function alternateSelectedControlTextColor lib CocoaLib selector "alternateSelectedControlTextColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = alternateSelectedControlTextColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Black() As NSColor
		  
		  #if targetMacOS
		    declare function blackColor lib CocoaLib selector "blackColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = blackColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function BlackComponent() As Single
		  
		  #if targetMacOS
		    declare function blackComponent lib CocoaLib selector "blackComponent" (id as Ptr) as Single
		    
		    return blackComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function BlendedColor(fraction as Single, aColor as NSColor) As NSColor
		  
		  #if targetMacOS
		    declare function blendedColorWithFraction lib CocoaLib selector "blendedColorWithFraction:ofColor:" _
		    (id as Ptr, fraction as Single, aColor as Ptr) as Ptr
		    
		    dim aColorRef as Ptr
		    if aColor <> nil then
		      aColorRef = aColor
		    end if
		    
		    dim colorRef as Ptr = blendedColorWithFraction(self, fraction, aColorRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused fraction
		    #pragma unused aColor
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Blue() As NSColor
		  
		  #if targetMacOS
		    declare function blueColor lib CocoaLib selector "blueColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = blueColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function BlueComponent() As Single
		  
		  #if targetMacOS
		    declare function blueComponent lib CocoaLib selector "blueComponent" (id as Ptr) as Single
		    
		    return blueComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function BrightnessComponent() As Single
		  
		  #if targetMacOS
		    declare function brightnessComponent lib CocoaLib selector "brightnessComponent" (id as Ptr) as Single
		    
		    return brightnessComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Brown() As NSColor
		  
		  #if targetMacOS
		    declare function brownColor lib CocoaLib selector "brownColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = brownColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function CatalogColor(listName as String, colorName as String) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithCatalogName lib CocoaLib selector "colorWithCatalogName:colorName:" _
		    (id as Ptr, listName as CFStringRef, colorName as CFStringRef) as Ptr
		    
		    dim colorRef as Ptr = colorWithCatalogName(ClassRef, listName, colorName)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused listName
		    #pragma unused colorName
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function CatalogNameComponent() As String
		  
		  #if targetMacOS
		    declare function catalogNameComponent lib CocoaLib selector "catalogNameComponent" (id as Ptr) as CFStringRef
		    
		    return catalogNameComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h21
		Private Shared Function ClassRef() As Ptr
		  
		  static ref as Ptr = Cocoa.NSClassFromString("NSColor")
		  return ref
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Clear() As NSColor
		  
		  #if targetMacOS
		    declare function clearColor lib CocoaLib selector "clearColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = clearColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function CMYKADeviceColor(cyan as Single, magenta as Single, yellow as Single, black as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithDeviceCyan lib CocoaLib selector "colorWithDeviceCyan:magenta:yellow:black:alpha:" _
		    (id as Ptr, cyan as Single, magenta as Single, yellow as Single, black as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithDeviceCyan(ClassRef, cyan, magenta, yellow, black, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused cyan
		    #pragma unused magenta
		    #pragma unused yellow
		    #pragma unused black
		    #pragma unused alpha
		  #endif
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ColorFromPasteboard(pasteBoard as NSPasteboard) As NSColor
		  
		  #if targetMacOS
		    declare function colorFromPasteboard lib CocoaLib selector "colorFromPasteboard:" (id as Ptr, pasteboard as Ptr) as Ptr
		    
		    dim pasteboardRef as Ptr
		    if pasteboard <> nil then
		      pasteboardRef = pasteboard
		    end if
		    
		    dim colorRef as Ptr = colorFromPasteboard(ClassRef, pasteboardRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused pasteboard
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function ColorNameComponent() As String
		  
		  #if targetMacOS
		    declare function colorNameComponent lib CocoaLib selector "colorNameComponent" (id as Ptr) as CFStringRef
		    
		    return colorNameComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function ColorSpace() As NSColorspace
		  
		  #if targetMacOS
		    declare function colorSpace lib CocoaLib selector "colorSpace" (id as Ptr) as Ptr
		    
		    dim spaceRef as Ptr = colorSpace(self)
		    if spaceRef <> nil then
		      return new NSColorspace(spaceRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ColorspaceColor(space as NSColorspace, components() as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithColorSpace lib CocoaLib selector "colorWithColorSpace:components:count:" _
		    (id as Ptr, space as Ptr, components as Ptr, count as Integer) as Ptr
		    
		    const sizeOfSingle = 4
		    
		    if space <> nil then
		      dim componentCount as Integer = components.ubound+1
		      dim m as new MemoryBlock(componentCount*sizeOfSingle)
		      for i as integer = 0 to componentCount-1
		        m.SingleValue(i*sizeOfSingle) = components(i)
		      next
		      
		      dim colorRef as Ptr = colorWithColorSpace(ClassRef, space, m, componentCount)
		      if colorRef <> nil then
		        return new NSColor(colorRef)
		      else
		        return nil
		      end if
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused space
		    #pragma unused components
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function ColorSpaceName() As String
		  
		  #if targetMacOS
		    declare function colorSpaceName lib CocoaLib selector "colorSpaceName" (id as Ptr) as CFStringRef
		    
		    return colorSpaceName(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function ColorWithAlpha(alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithAlphaComponent lib CocoaLib selector "colorWithAlphaComponent:" (id as Ptr, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithAlphaComponent(self, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused alpha
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function Components() As Single()
		  
		  #if targetMacOS
		    declare sub getComponents lib CocoaLib selector "getComponents:" (id as Ptr, components as Ptr)
		    
		    dim rb_array() as Single
		    
		    const sizeOfSingle = 4
		    
		    dim n as Integer = self.NumberOfComponents
		    dim m as new MemoryBlock(n*sizeOfSingle)
		    getComponents self, m
		    
		    for i as integer = 0 to n-1
		      rb_array.append m.SingleValue(i*sizeOfSingle)
		    next
		    
		    return rb_array
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h21
		Private Function ComputeColorValue() As Color
		  
		  #if targetMacOS
		    
		    dim c as NSColor = self.ConvertColorspace("NSCalibratedRGBColorSpace")
		    
		    #if RBVersion >= 2011.04 // RB 2011.04 and later supports colors with alpha value
		      
		      declare sub getRGBComponents lib CocoaLib selector "getRed:green:blue:alpha:" _
		      (id as Ptr, ByRef red as Single, ByRef green as Single, ByRef blue as Single, byRef alpha as Single)
		      
		      dim red as Single
		      dim green as Single
		      dim blue as Single
		      dim alpha as Single
		      
		      getRGBComponents c, red, green, blue, alpha
		      
		      return RGB(255.0*red, 255.0*green, 255.0*blue, (255.0-255.0)*alpha)
		      
		    #else
		      
		      declare sub getRGBComponents lib CocoaLib selector "getRed:green:blue:alpha:" _
		      (id as Ptr, ByRef red as Single, ByRef green as Single, ByRef blue as Single, alpha as Ptr)
		      
		      dim red as Single
		      dim green as Single
		      dim blue as Single
		      
		      getRGBComponents c, red, green, blue, nil
		      
		      return RGB(255.0*red, 255.0*green, 255.0*blue)
		      
		    #endif
		    
		  #endif
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub Constructor(c as Color, alpha as Double = 1.0)
		  
		  #if targetMacOS
		    declare function colorFromRGBA lib CocoaLib selector "colorWithCalibratedRed:green:blue:alpha:" _
		    (class_id as Ptr, red as Single, green as Single, blue as Single, alpha as Single) as Ptr
		    
		    #if RBVersion >= 2011.04 // RB 2011.04 and later supports colors with alpha value
		      #pragma unused alpha
		      super.Constructor(RGBACalibratedColor(c.Red/255, c.Green/255, c.Blue/255, (255-c.alpha)/255))
		    #else
		      super.Constructor(RGBACalibratedColor(c.Red/255, c.Green/255, c.Blue/255, alpha))
		    #endif
		    
		  #else
		    
		    #pragma unused c
		    #pragma unused alpha
		    
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlAlternatingRowBackgroundColors() As NSColor()
		  
		  #if targetMacOS
		    declare function controlAlternatingRowBackgroundColors lib CocoaLib selector "controlAlternatingRowBackgroundColors" (id as Ptr) as Ptr
		    
		    dim retArray() as NSColor
		    
		    dim arrayRef as Ptr = controlAlternatingRowBackgroundColors(ClassRef)
		    if arrayRef <> nil then
		      dim ns_array as new NSArray(arrayRef)
		      const sizeOfPtr = 4
		      dim arrayRange as Cocoa.NSRange = Cocoa.NSMakeRange(0, ns_array.Count)
		      dim m as MemoryBlock = ns_array.ValuesArray(arrayRange)
		      dim n as UInt32 = arrayRange.length-1
		      for i as integer = 0 to n
		        retArray.append new NSColor(Ptr(m.UInt32Value(i*sizeOfPtr)))
		      next
		    end if
		    
		    return retArray
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlBackgroundColor() As NSColor
		  
		  #if targetMacOS
		    declare function controlBackgroundColor lib CocoaLib selector "controlBackgroundColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = controlBackgroundColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlColor() As NSColor
		  
		  #if targetMacOS
		    declare function controlColor lib CocoaLib selector "controlColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = controlColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlDarkShadowColor() As NSColor
		  
		  #if targetMacOS
		    declare function controlDarkShadowColor lib CocoaLib selector "controlDarkShadowColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = controlDarkShadowColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlHighlightColor() As NSColor
		  
		  #if targetMacOS
		    declare function controlHighlightColor lib CocoaLib selector "controlHighlightColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = controlHighlightColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlLightHighlightColor() As NSColor
		  
		  #if targetMacOS
		    declare function controlLightHighlightColor lib CocoaLib selector "controlLightHighlightColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = controlLightHighlightColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlShadowColor() As NSColor
		  
		  #if targetMacOS
		    declare function controlShadowColor lib CocoaLib selector "controlShadowColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = controlShadowColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlTextColor() As NSColor
		  
		  #if targetMacOS
		    declare function controlTextColor lib CocoaLib selector "controlTextColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = controlTextColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlTint(controlTint as NSControlTint) As NSColor
		  
		  #if targetMacOS
		    declare function colorForControlTint lib CocoaLib selector "colorForControlTint:" (id as Ptr, controlTint as NSControlTint) as Ptr
		    
		    dim colorRef as Ptr = colorForControlTint(ClassRef, controlTint)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused controlTint
		  #endif
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlTintBlue() As NSColor
		  
		  return ControlTint(NSControlTint.NSBlueControlTint)
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlTintClear() As NSColor
		  
		  return ControlTint(NSControlTint.NSClearControlTint)
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlTintDefault() As NSColor
		  
		  return ControlTint(NSControlTint.NSDefaultControlTint)
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ControlTintGraphite() As NSColor
		  
		  return ControlTint(NSControlTint.NSGraphiteControlTint)
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function ConvertColorspace(colorSpace as NSColorspace) As NSColor
		  
		  #if targetMacOS
		    declare function colorUsingColorSpace lib CocoaLib selector "colorUsingColorSpace:" (obj_id as Ptr, colorSpace as Ptr) as Ptr
		    
		    dim colorSpaceRef as Ptr
		    if colorSpace <> nil then
		      colorSpaceRef = colorSpace
		    end if
		    
		    dim p as Ptr = colorUsingColorSpace(self, colorSpaceRef)
		    if p <> nil then
		      if p = self.id then
		        return self
		      else
		        return new NSColor(p)
		      end if
		    else
		      //conversion could not be done
		      return nil
		    end if
		    
		  #else
		    #pragma unused colorSpace
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function ConvertColorspace(spaceName as String) As NSColor
		  
		  #if targetMacOS
		    declare function colorUsingColorSpaceName lib CocoaLib selector "colorUsingColorSpaceName:" (id as Ptr, colorSpace as CFStringRef) as Ptr
		    
		    dim p as Ptr = colorUsingColorSpaceName(self, spaceName)
		    if p <> nil then
		      if p = self.id then
		        return self
		      else
		        return new NSColor(p)
		      end if
		    else
		      //conversion could not be done
		      return nil
		    end if
		    
		  #else
		    #pragma unused spaceName
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function ConvertColorspace(spaceName as String, deviceDescription as NSDictionary) As NSColor
		  
		  #if targetMacOS
		    declare function colorUsingColorSpaceName lib CocoaLib selector "colorUsingColorSpaceName:device:" _
		    (obj_id as Ptr, spaceName as CFStringRef, deviceDescription as Ptr) as Ptr
		    
		    dim dictRef as Ptr
		    if deviceDescription <> nil then
		      dictRef = deviceDescription
		    end if
		    
		    dim p as Ptr = colorUsingColorSpaceName(self, spaceName, dictRef)
		    if p <> nil then
		      if p = self.id then
		        return self
		      else
		        return new NSColor(p)
		      end if
		    else
		      //conversion could not be done
		      return nil
		    end if
		    
		  #else
		    #pragma unused spaceName
		    #pragma unused deviceDescription
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function CurrentControlTint() As NSControlTint
		  
		  #if targetMacOS
		    declare function currentControlTint lib CocoaLib selector "currentControlTint" (id as Ptr) as NSControlTint
		    
		    return currentControlTint(ClassRef)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Cyan() As NSColor
		  
		  #if targetMacOS
		    declare function cyanColor lib CocoaLib selector "cyanColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = cyanColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function CyanComponent() As Single
		  
		  #if targetMacOS
		    declare function cyanComponent lib CocoaLib selector "cyanComponent" (id as Ptr) as Single
		    
		    return cyanComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function DarkGray() As NSColor
		  
		  #if targetMacOS
		    declare function darkGrayColor lib CocoaLib selector "darkGrayColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = darkGrayColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function DisabledControlTextColor() As NSColor
		  
		  #if targetMacOS
		    declare function disabledControlTextColor lib CocoaLib selector "disabledControlTextColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = disabledControlTextColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub DrawSwatchInRect(rect as Cocoa.NSRect)
		  
		  #if targetMacOS
		    declare sub drawSwatchInRect lib CocoaLib selector "drawSwatchInRect:" (id as Ptr, rect as Cocoa.NSRect)
		    
		    drawSwatchInRect self, rect
		    
		  #else
		    #pragma unused rect
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function GenericGamma22Color(white as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithGenericGamma22White lib CocoaLib selector "colorWithGenericGamma22White:alpha:" _
		    (id as Ptr, white as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithGenericGamma22White(ClassRef, white, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused white
		    #pragma unused alpha
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub GetCMYKA(byRef cyan as Single, byRef magenta as Single, byRef yellow as Single, byRef black as Single, byRef alpha as Single)
		  
		  #if targetMacOS
		    declare sub getCyan lib CocoaLib selector "getCyan:magenta:yellow:black:alpha:" _
		    (id as Ptr, byRef cyan as Single, byRef magenta as Single, byRef yellow as Single, byRef black as Single, byRef alpha as Single)
		    
		    getCyan self, cyan, magenta, yellow, black, alpha
		    
		  #else
		    #pragma unused cyan
		    #pragma unused magenta
		    #pragma unused yellow
		    #pragma unused black
		    #pragma unused alpha
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub GetHSBA(byRef hue as Single, byRef saturation as Single, byRef brightness as Single, byRef alpha as Single)
		  
		  #if targetMacOS
		    declare sub getHue lib CocoaLib selector "getHue:saturation:brightness:alpha:" _
		    (id as Ptr, byRef hue as Single, byRef saturation as Single, byRef brightness as Single, byRef alpha as Single)
		    
		    getHue self, hue, saturation, brightness, alpha
		    
		  #else
		    #pragma unused hue
		    #pragma unused saturation
		    #pragma unused brightness
		    #pragma unused alpha
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub GetRGBA(byRef red as Single, byRef green as Single, byRef blue as Single, byRef alpha as Single)
		  
		  #if targetMacOS
		    declare sub getRed lib CocoaLib selector "getRed:green:blue:alpha:" _
		    (id as Ptr, byRef red as Single, byRef green as Single, byRef blue as Single, byRef alpha as Single)
		    
		    getRed self, red, green, blue, alpha
		    
		  #else
		    #pragma unused red
		    #pragma unused green
		    #pragma unused blue
		    #pragma unused alpha
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub GetWA(byRef white as Single, byRef alpha as Single)
		  
		  #if targetMacOS
		    declare sub getWhite lib CocoaLib selector "getWhite:alpha:" (id as Ptr, byRef white as Single, byRef alpha as Single)
		    
		    getWhite self, white, alpha
		    
		  #else
		    #pragma unused white
		    #pragma unused alpha
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Gray() As NSColor
		  
		  #if targetMacOS
		    declare function grayColor lib CocoaLib selector "grayColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = grayColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Green() As NSColor
		  
		  #if targetMacOS
		    declare function greenColor lib CocoaLib selector "greenColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = greenColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GreenComponent() As Single
		  
		  #if targetMacOS
		    declare function greenComponent lib CocoaLib selector "greenComponent" (id as Ptr) as Single
		    
		    return greenComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function GridColor() As NSColor
		  
		  #if targetMacOS
		    declare function gridColor lib CocoaLib selector "gridColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = gridColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function HeaderColor() As NSColor
		  
		  #if targetMacOS
		    declare function headerColor lib CocoaLib selector "headerColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = headerColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function HeaderTextColor() As NSColor
		  
		  #if targetMacOS
		    declare function headerTextColor lib CocoaLib selector "headerTextColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = headerTextColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function Highlight(highlightLevel as Single) As NSColor
		  
		  #if targetMacOS
		    declare function highlightWithLevel lib CocoaLib selector "highlightWithLevel:" (id as Ptr, highlightLevel as Single) as Ptr
		    
		    dim colorRef as Ptr = highlightWithLevel(self, highlightLevel)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused highlightLevel
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function HighlightColor() As NSColor
		  
		  #if targetMacOS
		    declare function highlightColor lib CocoaLib selector "highlightColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = highlightColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function HSBACalibratedColor(hue as Single, saturation as Single, brightness as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithCalibratedHue lib CocoaLib selector "colorWithCalibratedHue:saturation:brightness:alpha:" _
		    (id as Ptr, hue as Single, saturation as Single, brightness as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithCalibratedHue(ClassRef, hue, saturation, brightness, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused hue
		    #pragma unused saturation
		    #pragma unused brightness
		    #pragma unused alpha
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function HSBADeviceColor(hue as Single, saturation as Single, brightness as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithDeviceHue lib CocoaLib selector "colorWithDeviceHue:saturation:brightness:alpha:" _
		    (id as Ptr, hue as Single, saturation as Single, brightness as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithDeviceHue(ClassRef, hue, saturation, brightness, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused hue
		    #pragma unused saturation
		    #pragma unused brightness
		    #pragma unused alpha
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function HueComponent() As Single
		  
		  #if targetMacOS
		    declare function hueComponent lib CocoaLib selector "hueComponent" (id as Ptr) as Single
		    
		    return hueComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function KeyboardFocusIndicatorColor() As NSColor
		  
		  #if targetMacOS
		    declare function keyboardFocusIndicatorColor lib CocoaLib selector "keyboardFocusIndicatorColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = keyboardFocusIndicatorColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function KnobColor() As NSColor
		  
		  #if targetMacOS
		    declare function knobColor lib CocoaLib selector "knobColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = knobColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function LightGray() As NSColor
		  
		  #if targetMacOS
		    declare function lightGrayColor lib CocoaLib selector "lightGrayColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = lightGrayColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function LocalizedCatalogNameComponent() As String
		  
		  #if targetMacOS
		    declare function localizedCatalogNameComponent lib CocoaLib selector "localizedCatalogNameComponent" (id as Ptr) as CFStringRef
		    
		    return localizedCatalogNameComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function LocalizedColorNameComponent() As String
		  
		  #if targetMacOS
		    declare function localizedColorNameComponent lib CocoaLib selector "localizedColorNameComponent" (id as Ptr) as CFStringRef
		    
		    return localizedColorNameComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Magenta() As NSColor
		  
		  #if targetMacOS
		    declare function magentaColor lib CocoaLib selector "magentaColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = magentaColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function MagentaComponent() As Single
		  
		  #if targetMacOS
		    declare function magentaComponent lib CocoaLib selector "magentaComponent" (id as Ptr) as Single
		    
		    return magentaComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function NumberOfComponents() As Integer
		  
		  #if targetMacOS
		    declare function numberOfComponents lib CocoaLib selector "numberOfComponents" (id as Ptr) as Integer
		    
		    return numberOfComponents(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function Operator_Convert() As Color
		  
		  return self.ColorValue
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub Operator_Convert(aColor as Color)
		  
		  self.Constructor(aColor)
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Orange() As NSColor
		  
		  #if targetMacOS
		    declare function orangeColor lib CocoaLib selector "orangeColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = orangeColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function PatternImage() As NSImage
		  
		  #if targetMacOS
		    declare function patternImage lib CocoaLib selector "patternImage" (id as Ptr) as Ptr
		    
		    dim imageRef as Ptr = patternImage(self)
		    if imageRef <> nil then
		      return new NSImage(imageRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function PatternImageColor(image as NSImage) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithPatternImage lib CocoaLib selector "colorWithPatternImage:" (id as Ptr, image as Ptr) as Ptr
		    
		    dim imageRef as Ptr
		    if image <> nil then
		      imageRef = image
		    end if
		    
		    dim colorRef as Ptr = colorWithPatternImage(ClassRef, imageRef)
		    
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused image
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Purple() As NSColor
		  
		  #if targetMacOS
		    declare function purpleColor lib CocoaLib selector "purpleColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = purpleColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Red() As NSColor
		  
		  #if targetMacOS
		    declare function redColor lib CocoaLib selector "redColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = redColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function RedComponent() As Single
		  
		  #if targetMacOS
		    declare function redComponent lib CocoaLib selector "redComponent" (id as Ptr) as Single
		    
		    return redComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function RGBACalibratedColor(red as Single, green as Single, blue as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithCalibratedRed lib CocoaLib selector "colorWithCalibratedRed:green:blue:alpha:" _
		    (id as Ptr, red as Single, green as Single, blue as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithCalibratedRed(ClassRef, red, green, blue, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused red
		    #pragma unused green
		    #pragma unused blue
		    #pragma unused alpha
		  #endif
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function RGBADeviceColor(red as Single, green as Single, blue as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithDeviceRed lib CocoaLib selector "colorWithDeviceRed:green:blue:alpha:" _
		    (id as Ptr, red as Single, green as Single, blue as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithDeviceRed(ClassRef, red, green, blue, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused red
		    #pragma unused green
		    #pragma unused blue
		    #pragma unused alpha
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function SaturationComponent() As Single
		  
		  #if targetMacOS
		    declare function saturationComponent lib CocoaLib selector "saturationComponent" (id as Ptr) as Single
		    
		    return saturationComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ScrollBarColor() As NSColor
		  
		  #if targetMacOS
		    declare function scrollBarColor lib CocoaLib selector "scrollBarColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = scrollBarColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SecondarySelectedControlColor() As NSColor
		  
		  #if targetMacOS
		    declare function secondarySelectedControlColor lib CocoaLib selector "secondarySelectedControlColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = secondarySelectedControlColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SelectedControlColor() As NSColor
		  
		  #if targetMacOS
		    declare function selectedControlColor lib CocoaLib selector "selectedControlColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = selectedControlColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SelectedControlTextColor() As NSColor
		  
		  #if targetMacOS
		    declare function selectedControlTextColor lib CocoaLib selector "selectedControlTextColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = selectedControlTextColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SelectedKnobColor() As NSColor
		  
		  #if targetMacOS
		    declare function selectedKnobColor lib CocoaLib selector "selectedKnobColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = selectedKnobColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SelectedMenuItemColor() As NSColor
		  
		  #if targetMacOS
		    declare function selectedMenuItemColor lib CocoaLib selector "selectedMenuItemColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = selectedMenuItemColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SelectedMenuItemTextColor() As NSColor
		  
		  #if targetMacOS
		    declare function selectedMenuItemTextColor lib CocoaLib selector "selectedMenuItemTextColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = selectedMenuItemTextColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SelectedTextBackgroundColor() As NSColor
		  
		  #if targetMacOS
		    declare function selectedTextBackgroundColor lib CocoaLib selector "selectedTextBackgroundColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = selectedTextBackgroundColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SelectedTextColor() As NSColor
		  
		  #if targetMacOS
		    declare function selectedTextColor lib CocoaLib selector "selectedTextColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = selectedTextColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub SetColor()
		  
		  #if targetMacOS
		    declare sub set_ lib CocoaLib selector "set" (id as Ptr)
		    
		    set_ self
		    
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub SetFillColor()
		  
		  #if targetMacOS
		    declare sub setFill lib CocoaLib selector "setFill" (id as Ptr)
		    
		    setFill self
		    
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub SetStrokeColor()
		  
		  #if targetMacOS
		    declare sub setStroke lib CocoaLib selector "setStroke" (id as Ptr)
		    
		    setStroke self
		    
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Function Shadow(shadowLevel as Single) As NSColor
		  
		  #if targetMacOS
		    declare function shadowWithLevel lib CocoaLib selector "shadowWithLevel:" (id as Ptr, shadowLevel as Single) as Ptr
		    
		    dim colorRef as Ptr = shadowWithLevel(self, shadowLevel)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused shadowLevel
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function ShadowColor() As NSColor
		  
		  #if targetMacOS
		    declare function shadowColor lib CocoaLib selector "shadowColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = shadowColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function SRGBColor(red as Single, green as Single, blue as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithSRGBRed lib CocoaLib selector "colorWithSRGBRed:green:blue:alpha:" _
		    (id as Ptr, red as Single, green as Single, blue as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithSRGBRed(ClassRef, red, green, blue, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused red
		    #pragma unused green
		    #pragma unused blue
		    #pragma unused alpha
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function TextBackgroundColor() As NSColor
		  
		  #if targetMacOS
		    declare function textBackgroundColor lib CocoaLib selector "textBackgroundColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = textBackgroundColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function TextColor() As NSColor
		  
		  #if targetMacOS
		    declare function textColor lib CocoaLib selector "textColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = textColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function VariantValue() As Variant
		  
		  return self.ColorValue
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function WACalibratedColor(white as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithCalibratedWhite lib CocoaLib selector "colorWithCalibratedWhite:alpha:" _
		    (id as Ptr, white as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithCalibratedWhite(ClassRef, white, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused white
		    #pragma unused alpha
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function WADeviceColor(white as Single, alpha as Single) As NSColor
		  
		  #if targetMacOS
		    declare function colorWithDeviceWhite lib CocoaLib selector "colorWithDeviceWhite:alpha:" _
		    (id as Ptr, white as Single, alpha as Single) as Ptr
		    
		    dim colorRef as Ptr = colorWithDeviceWhite(ClassRef, white, alpha)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #else
		    #pragma unused white
		    #pragma unused alpha
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function White() As NSColor
		  
		  #if targetMacOS
		    declare function whiteColor lib CocoaLib selector "whiteColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = whiteColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function WhiteComponent() As Single
		  
		  #if targetMacOS
		    declare function whiteComponent lib CocoaLib selector "whiteComponent" (id as Ptr) as Single
		    
		    return whiteComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function WindowBackgroundColor() As NSColor
		  
		  #if targetMacOS
		    declare function windowBackgroundColor lib CocoaLib selector "windowBackgroundColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = windowBackgroundColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function WindowFrameColor() As NSColor
		  
		  #if targetMacOS
		    declare function windowFrameColor lib CocoaLib selector "windowFrameColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = windowFrameColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function WindowFrameTextColor() As NSColor
		  
		  #if targetMacOS
		    declare function windowFrameTextColor lib CocoaLib selector "windowFrameTextColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = windowFrameTextColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub WriteToPasteboard(pasteboard as NSPasteboard)
		  
		  #if targetMacOS
		    declare sub writeToPasteboard lib CocoaLib selector "writeToPasteboard:" (id as Ptr, pasteboard as Ptr)
		    
		    dim pasteboardRef as Ptr
		    if pasteboard <> nil then
		      pasteboardRef = pasteboard
		    end if
		    
		    writeToPasteboard self, pasteboardRef
		    
		  #else
		    #pragma unused pasteboard
		  #endif
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		 Shared Function Yellow() As NSColor
		  
		  #if targetMacOS
		    declare function yellowColor lib CocoaLib selector "yellowColor" (id as Ptr) as Ptr
		    
		    dim colorRef as Ptr = yellowColor(ClassRef)
		    if colorRef <> nil then
		      return new NSColor(colorRef)
		    else
		      return nil
		    end if
		    
		  #endif
		  
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function YellowComponent() As Single
		  
		  #if targetMacOS
		    declare function yellowComponent lib CocoaLib selector "yellowComponent" (id as Ptr) as Single
		    
		    return yellowComponent(self)
		    
		  #endif
		  
		End Function
	#tag EndMethod


	#tag ComputedProperty, Flags = &h0
		#tag Getter
			Get
			  
			  #if targetMacOS
			    declare function colorSpaceName lib CocoaLib selector "colorSpaceName" (id as Ptr) as CFStringRef
			    
			    return colorSpaceName(self)
			    
			  #endif
			End Get
		#tag EndGetter
		ColorspaceName As String
	#tag EndComputedProperty

	#tag ComputedProperty, Flags = &h0
		#tag Getter
			Get
			  //On my machine, the first invocation of ComputeColorValue takes 1000 µs; subsequent invocations take around 20µs.  With caching, subsequent invocations
			  //take around 1 µs.  Since the caching is internal, simply implemented and NSColor as implemented here is immutable, I figure it's worth the one-time effort.
			  
			  if not self.rbcolorcomputed then
			    self.rbcolor = self.ComputeColorValue
			    self.rbcolorcomputed = true
			  end if
			  
			  return self.rbcolor
			  
			End Get
		#tag EndGetter
		ColorValue As Color
	#tag EndComputedProperty

	#tag ComputedProperty, Flags = &h0
		#tag Getter
			Get
			  
			  #if targetMacOS
			    declare function ignoresAlpha lib CocoaLib selector "ignoresAlpha" (id as Ptr) as Boolean
			    
			    return ignoresAlpha(ClassRef)
			    
			  #endif
			  
			End Get
		#tag EndGetter
		#tag Setter
			Set
			  
			  #if targetMacOS
			    declare sub setIgnoresAlpha lib CocoaLib selector "setIgnoresAlpha:" (id as Ptr, flag as Boolean)
			    
			    setIgnoresAlpha ClassRef, value
			    
			  #else
			    #pragma unused value
			  #endif
			  
			End Set
		#tag EndSetter
		Shared IgnoresAlpha As Boolean
	#tag EndComputedProperty

	#tag Property, Flags = &h21
		Attributes( Hidden = true ) Private rbcolor As Color
	#tag EndProperty

	#tag Property, Flags = &h21
		Attributes( Hidden = true ) Private rbcolorcomputed As Boolean
	#tag EndProperty


	#tag Enum, Name = NSControlTint, Type = UInt32, Flags = &h0
		NSDefaultControlTint = 0
		  NSBlueControlTint = 1
		  NSGraphiteControlTint = 6
		NSClearControlTint = 7
	#tag EndEnum


	#tag ViewBehavior
		#tag ViewProperty
			Name="ColorspaceName"
			Group="Behavior"
			Type="String"
			EditorType="MultiLineEditor"
		#tag EndViewProperty
		#tag ViewProperty
			Name="ColorValue"
			Group="Behavior"
			InitialValue="&h000000"
			Type="Color"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Description"
			Group="Behavior"
			Type="String"
			EditorType="MultiLineEditor"
			InheritedFrom="NSObject"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InitialValue="-2147483648"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
	#tag EndViewBehavior
End Class
#tag EndClass
